import * as types from '../mutation';

const state = {
    screenSize:{},
    userInfo:{},
    currentJob:{},
    loadingStatus:false
}

const actions = {
    //获取屏幕尺寸
    setScreenSize:function ({commit},data) {
        commit(types.SCREEN_SIZE,data);
    },
    //单个数值
    setBannerSizeInfo:function ({commit},date) {
        commit(types.BANNER_SIZE_INFO,date);
    },
    //用户信息
    setUserInfo:function ({commit},data) {
        commit(types.USER_INFO,data);
    },
    //当前工作
    setCurrentJob:function ({commit},data) {
        commit(types.CURRENT_JOB,data);
    },
    setLoadingStatus:function ({commit},data){
      commit(types.LOADING_STATUS,data);
    },
}

const mutations = {
    [types.SCREEN_SIZE](state,data){
        state.screenSize = data
    },
    [types.BANNER_SIZE_INFO](state,data){
        state.bannerSizeInfo = data
    },
    [types.USER_INFO](state,data){
        state.userInfo = data
    },
    [types.CURRENT_JOB](state,data){
        state.currentJob = data
    },
    [types.LOADING_STATUS](state,data){
        state.loadingStatus = data
    },
}

const getters = {
    getScreenSize :state => state.screenSize,
    getBannerSizeInfo :state => state.bannerSizeInfo,
    getUserInfo :state => state.userInfo,
    getCurrentJob :state => state.currentJob,
    getLoadingStatus :state => state.loadingStatus
}

export default {
    state,
    actions,
    mutations,
    getters
}
